package com.ruoyi.system.enumeration;

import lombok.Getter;
import lombok.AllArgsConstructor;

/**
 * 自助预定订单状态枚举
 */
@Getter
@AllArgsConstructor
public enum SelfServiceBookingStatusEnum {

    /**
     * 待付款
     */
    WAIT_PAYMENT(1, "待付款"),

    /**
     * 支付成功
     */
    PAID(2, "支付成功"),

    /**
     * 已取消
     */
    CANCELED(3, "已取消"),

    /**
     * 消费中
     */
    CONSUMING(4, "消费中"),

    /**
     * 已完成
     */
    COMPLETED(5, "已完成");

    private final Integer code;
    private final String description;

    /**
     * 根据 code 获取枚举项
     */
    public static SelfServiceBookingStatusEnum fromCode(Integer code) {
        for (SelfServiceBookingStatusEnum status : values()) {
            if (status.code.equals(code)) {
                return status;
            }
        }
        throw new IllegalArgumentException("Invalid status code: " + code);
    }

    /**
     * 根据 code 获取描述信息
     */
    public static String getDescriptionByCode(Integer code) {
        return fromCode(code).description;
    }
}
